package mailserver.sql;

import java.sql.*;
import com.mysql.jdbc.Driver;
import java.util.logging.*;

/**
 * Creates new Connection objects for specified DB.
 * @author Alisa Bakaeva
 */
public class DBController {

    private static DBController dbcontr = null;

    protected Connection createConnection() throws SQLException {
        Connection con  = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/mail_first_project",
                "root", "admin");

        return con;
    }
    
    private DBController() 
            throws SQLException {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DBController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    protected static DBController getInstance() 
            throws SQLException {
        if (dbcontr == null) {
            dbcontr = new DBController();
        }
        return dbcontr;
    }

}